package bma.common.httpclient;

import bma.common.langutil.core.ValueUtil;
import bma.common.langutil.log.LogbackUtil;

public class HttpClientUtil {

	public static void disableDebug(boolean all) {
		if (all) {
			LogbackUtil.setLevel("org.apache.http", "INFO");
		} else {
			LogbackUtil.setLevel("org.apache.http.wire", "INFO");
			LogbackUtil.setLevel("org.apache.http.headers", "INFO");
			LogbackUtil.setLevel("org.apache.http.client.protocol", "INFO");
			LogbackUtil.setLevel("org.apache.http.impl.conn.tsccm", "INFO");
			LogbackUtil.setLevel("org.apache.http.impl.conn.tsccm", "INFO");
		}
	}

	public static String appendUrlParam(String url, String pstr) {
		if (ValueUtil.empty(pstr)) {
			return url;
		}
		if (url.indexOf('?') == -1) {
			return url + "?" + pstr;
		}
		return url + "&" + pstr;
	}
}
